<%- include fheader.ejs%>

<header class="ui-header ui-header-stable ui-border-b">
        <h1>登录</h1>
    </header>
    <section  class="ui-container">

        <div class="ui-form ui-border-t">
            <form>

                <div class="ui-form-item ui-form-item-show ui-border-b">
                    <label>
                        账号
                    </label>
                    <input type="text" id="username" placeholder="请输入账号" value=""/>
                </div>
                <div class="ui-form-item ui-form-item-show ui-border-b">
                    <label>
                        密码
                    </label>
                    <input  id="password" type="password" placeholder="请输入密码" value=""/>
                </div>
                <div class="ui-form-item ui-form-item-show ui-border-b">
                    <label>
                        真实姓名
                    </label>
                    <input  id="realname" type="text" placeholder="请输入姓名" value=""/>
                </div>
                <div style="text-align: center;padding: 15px">
                    <input type="hidden" id="token" name="_token" value="<%= token%>">
                    <button id="btnLogin" type="button" class="ui-btn ui-btn-primary ui-btn-lg">登录</button>
                </div>

            </form>
        </div>

    </section>
<script src="//cdn.juqingdata.com/assets/js/hashes.js"></script>

<script>
    $(function(){
        var LOGIN_URL = '/rest/svcWx/mdUserChannelLoginCheck';
        var CHANNEL_URL = '<%= retUrl%>'||'/rest/wx/operorder';
        $('#btnLogin').tap(function(){
            if(!check()){
                return;
            }
            var p = {
                name: $('#username').val(),
                password:new Hashes.SHA256().hex($('#password').val()),
                realname: $('#realname').val(),
                token:$('#token').val()
            };
            juq.fpost(LOGIN_URL,p,function(){
                location.href = CHANNEL_URL;
            });
        });

        function check(){
            var res = true;
            $('.ui-form-item input').each(function () {
                if($(this).val()==''){
                    juq.showTipInfo('输入框不能为空');
                    res = false;
                    return false;
                }
            });
            return res;
        }
    })
</script>
<%- include ftailer.ejs%>